//
//  MJPhotoToolbar.m
//  FingerNews
//
//  Created by mj on 13-9-24.
//  Copyright (c) 2013年 itcast. All rights reserved.
//

#import "MJPhotoToolbar.h"
#import "MJPhoto.h"
//#import "MBProgressHUD+Add.h"

@interface MJPhotoToolbar()
{
    // 显示页码
    UIButton *_indexButton;
}
@end

@implementation MJPhotoToolbar

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setPhotos:(NSArray *)photos
{
    _photos = photos;
    
    _indexButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _indexButton.userInteractionEnabled = NO;
    _indexButton.bounds = CGRectMake(0, 0, 65.0f, 29.0f);
    _indexButton.titleLabel.font = [UIFont systemFontOfSize:17.0f];
    _indexButton.center = CGPointMake([UIScreen mainScreen].bounds.size.width * 0.5, 10.0f);
    [_indexButton setBackgroundImage:[UIImage imageNamed:@"blog_page_index"] forState:UIControlStateNormal];
    [self addSubview:_indexButton];
}

- (void)setCurrentPhotoIndex:(NSUInteger)currentPhotoIndex
{
    _currentPhotoIndex = currentPhotoIndex;
    
    // 更新页码
    [_indexButton setTitle:[NSString stringWithFormat:@"%d / %d",  (int)(_currentPhotoIndex + 1), (int)_photos.count] forState:UIControlStateNormal];
}

@end
